package top.wherewego.vnt;

import com.kongzue.baseframework.BaseApp;
import com.kongzue.dialogx.DialogX;
import com.kongzue.dialogx.style.MIUIStyle;

import java.util.ArrayList;
import java.util.List;

import top.wherewego.vnt.utils.DataHelper;
import top.wherewego.vnt.bean.Conf;

public class APP extends BaseApp<APP> {
    private static List<Conf> confList;

    @Override
    public void init() {
        DialogX.init(this);
        DialogX.globalStyle = new MIUIStyle();
    }


    public static List<Conf> getConfList() {
        confList = DataHelper.getDeviceData("configs");
        if (confList == null) {
            confList = new ArrayList<>();
        }
        return confList;
    }

    public static void addConfList(Conf conf) {
        getConfList();
        if (confList == null) {
            confList = new ArrayList<>();
        }
        confList.add(conf);
        confList.removeIf(confTor -> confTor.getConName() == null);
        DataHelper.saveDeviceData("configs", confList);
    }

    public static void deleteConf(int index){
        getConfList();
        if (confList == null) {
            confList = new ArrayList<>();
            return;
        }
        confList.remove(index);
        DataHelper.saveDeviceData("configs", confList);
    }
}
